-- <movevent type="AddItem" tileitem="1" itemid="5901" event="script" value="RPG/wood.lua"/>
--- maked by Kronos aka Hellboy ---

local transform_wood_table = { --- [moveitem.itemid] = {woodCount, moveitemCount (nil = 1), newId, newCount (nil = 1), effect (nil = standard), groundId (nil = dont seerch tile item), lvl (nil = 1), mlvl (nil = 0), mana, soul}
	[5878] = {woodCount = 2, moveitemCount = 2, newId = 2456, effect = CONST_ME_BLOCKHIT} --- bow
}

function onAddItem(moveitem, tileitem, position)

--[[
	local WOOD = nil
	WOOD = transform_wood_table[moveitem.itemid]
	if WOOD == nil then
		return false
	end
	WOOD.moveitemCount = (WOOD.moveitemCount == nil) and 0 or WOOD.moveitemCount
	
	if WOOD.woodCount ~= tileitem.type or WOOD.moveitemCount ~= moveitem.type or (WOOD.groundId ~= nil and getThingFromPos({x = position.x, y = position.y, z = position.z, stackpos = STACKPOS_GROUND}).itemid ~= WOOD.groundId) then
		return false
	end
	WOOD.newCount = (WOOD.newCount == nil) and 1 or WOOD.newCount
	WOOD.effect = (WOOD.effect == nil) and CONST_ME_BLOCKHIT or WOOD.effect
	
	doRemoveItem(moveitem.uid)
	doRemoveItem(tileitem.uid)
	doSendMagicEffect(position, WOOD.effect)
	if WOOD.newId ~= nil and WOOD.newId ~= 0 then
		if WOOD.oldCount ~= nil then
			if moveitem.type == WOOD.oldCount then
				doCreateItem(WOOD.newId, WOOD.newCount, position)
			else
				return false
			end
		else
			doCreateItem(WOOD.newId, WOOD.newCount, position)
		end
	end
	
	]]
	local WOOD = nil
	WOOD = transform_wood_table[moveitem.itemid]
	
	if WOOD ~= nil and tileitem.type == WOOD.woodCount then
		craftingMovements(moveitem, tileitem, position, WOOD)
		doRemoveItem(tileitem.uid)
	end
	
	return true
end